package com.bdqn.config.shiro;

import org.apache.shiro.mgt.DefaultSecurityManager;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ShiroConfig {
@Bean
    public MyShiroRealm myShiroRealm(){
    MyShiroRealm shiroRealm = new MyShiroRealm();
    return shiroRealm;
}
/**
 * 已经弃用不能使用
 */
//@Bean
//    public SecurityManager securityManager(){
//    DefaultSecurityManager securityManager = new DefaultSecurityManager();
//    securityManager.setRealm(myShiroRealm());
//    return securityManager;
//    }

    @Bean
    public ShiroFilterFactoryBean shiroFilterFactoryBean(DefaultSecurityManager securityManager){
    ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    shiroFilterFactoryBean.setSecurityManager(securityManager);
    return shiroFilterFactoryBean;
    }
}
